home *** CD-ROM | disk | FTP | other *** search
/ Joystick Magazine 1996 May / cd joy 71No13.iso / pc / demos / eurosoc / source / euro_inp.cpp < prev    next >
C/C++ Source or Header  |  1996-03-14  |  4KB  |  135 lines

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include <conio.h>
  5.  
  6. #include "eurodefs.h"
  7. #include "euro_fxd.h"
  8. #include "euro.equ"
  9. #include "euro_sym.h"
  10. #include "euro_def.h"
  11. #include "euro_var.h"
  12. #include "euro_gen.h"
  13. #include "euro_grf.h"
  14. #include "euro_dsk.h"
  15. #include "euro_fix.h"
  16. #include "euro_sel.h"
  17. #include "euro_inf.h"
  18. #include "euro_cnt.h"
  19. #include "euro_usr.h"
  20. #include "euro_net.h"
  21. #include "euro_spt.h"
  22.  
  23. #include "defines.h"
  24. extern     char    return_doskey;
  25.  
  26.  
  27.  
  28. //********************************************************************************************************************************
  29.  
  30. short    DoTextINPUT( char *string, short cursor, short MaxChars, char input, char state )
  31.     {
  32.         return_doskey    =    TRUE;
  33.  
  34.                strcpy( TextEditBuffer, string );
  35.              short    StringLength = strlen (string);
  36.  
  37.  
  38.         
  39.         if (kbhit())
  40.         {
  41.  
  42.             if ( (KeyInput[0] = getch()) == 0)
  43.                 KeyInput[1] = getch();
  44.  
  45.                 // Function Key Controlers
  46.  
  47.                 if (KeyInput[0]==0)
  48.                 {            
  49.  
  50.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  51.                 //∫               LEFT ARROW               ∫
  52.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  53.  
  54.                            if ( KeyInput[1]==L_ARROW && cursor > 0 )
  55.                         cursor--;
  56.                         
  57.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  58.                 //∫              RIGHT ARROW               ∫
  59.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  60.  
  61.                            if ( KeyInput[1]==R_ARROW && cursor < StringLength )
  62.                         cursor++;
  63.  
  64.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  65.                 //∫                  HOME                  ∫
  66.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  67.  
  68.                            if ( KeyInput[1]==HOME )
  69.                         cursor = 0;
  70.  
  71.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  72.                 //∫                  END                   ∫
  73.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  74.  
  75.                            if ( KeyInput[1]==END )
  76.                         cursor = StringLength;
  77.  
  78.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  79.                 //∫                DELETE                  ∫
  80.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  81.  
  82.                            if ( KeyInput[1]==DELETE && cursor < StringLength )
  83.                         for ( short c=cursor; c < StringLength+1; c++)
  84.                         { TextEditBuffer[c] = TextEditBuffer[c+1]; }                                                                         
  85.                        }
  86.  
  87.                 else
  88.  
  89.                 // Normal Key Control
  90.  
  91.                 {
  92.  
  93.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  94.                 //∫               BACKSPACE                ∫
  95.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  96.  
  97.                     if ( KeyInput[0]==B_SPACE && cursor > 0 )
  98.                         { for ( short c=cursor; c < StringLength+1; c++)
  99.                         { TextEditBuffer[c-1] = TextEditBuffer[c]; } cursor--;}                                                                         
  100.  
  101.  
  102.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  103.                 //∫                 RETURN                 ∫
  104.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  105.  
  106.                            if ( KeyInput[0]==RETURN )
  107.                         EuroTextEditState = 0;
  108.                         
  109.                 //…ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕª 
  110.                 //∫            NORMAL KEYPRESS             ∫
  111.                 //»ÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕÕº 
  112.  
  113.                     if ( KeyInput[0] > 31 && 
  114.                         KeyInput[0] < 128 && 
  115.                             StringLength < MaxChars && 
  116.                                 state == ENABLE_INPUT)
  117.                     {                              
  118.                         if ( (input == NORMAL) || (input == DIAL && LegalDial[ KeyInput[0] ] < 128) )
  119.                         {                        
  120.                             if ( cursor < (StringLength+1) )
  121.                                 for ( short c=StringLength+3; c > cursor; c--)
  122.                                 { TextEditBuffer[c] = TextEditBuffer[c-1]; }                                                                         
  123.                             TextEditBuffer[cursor] = KeyInput[0];
  124.                             cursor++;
  125.                         }
  126.                     }
  127.                 }
  128.  
  129.             return_doskey    =    FALSE;
  130.         }
  131.                                                      
  132.         return(cursor);
  133.     }
  134.  
  135.